package com.framework.loippi.tencent.IM;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.framework.loippi.utils.*;

import java.util.*;

public class TXCloudUtils {

    public static final String nickname = "Tag_Profile_IM_Nick";//昵称
    public static final String sex = "Tag_Profile_IM_Gender";//性别
    public static final String image = "Tag_Profile_IM_Image";//头像
    public static final String remark = "Tag_SNS_IM_Remark";//备注
    public static final String male = "Gender_Type_Male";//男
    public static final String female = "Gender_Type_Female";//女

    /**
     * 账号绑定
     *
     * @param uid      用户uid
     * @param nickname 用户昵称
     * @param image    用户头像
     * @return
     */
    public static byte AccountImport(String uid, String nickname, String image) {
        Map<String, String> map = new HashMap<String, String>();
        map.put("Identifier", uid);
        map.put("Nick", nickname);
        map.put("FaceUrl", image);
        String json = JSON.toJSONString(map);//拼装json数据
        JSONObject jObject = JSON.parseObject(TXCloudHelper.executePost(TXCloudHelper.getUrl(CloudData.accountImport), json));
        return jObject.get("ActionStatus").toString().equals("OK") ? (byte) 1 : (byte) 0;
    }
    /**
     * 账号绑定--机器人账号
     *
     * @param uid      用户uid
     * @param nickname 用户昵称
     * @param image    用户头像
     * @return
     */
    public static byte AccountImportRobot(String uid, String nickname, String image) {
    	Map<String, String> map = new HashMap<String, String>();
    	map.put("Identifier", uid);
    	map.put("Nick", nickname);
    	map.put("FaceUrl", image);
    	map.put("type", "2");
    	String json = JSON.toJSONString(map);//拼装json数据
    	JSONObject jObject = JSON.parseObject(TXCloudHelper.executePost(TXCloudHelper.getUrl(CloudData.accountImport), json));
    	return jObject.get("ActionStatus").toString().equals("OK") ? (byte) 1 : (byte) 0;
    }

    /**
     * 管理员向其他指定账户发送消息
     *
     * @param uid
     * @param msg
     * @return
     */
    public static byte OpenimSendMsg(String uid, String msg) {
        Map<Object, Object> map = new HashMap<Object, Object>();//拼装json数据
        List<Object> list = new ArrayList<Object>();
        list.add(setMsgBody(msg));//消息体内容
        map.put("SyncOtherMachine", 1);//1：把消息同步到From_Account在线终端和漫游上；2：消息不同步至From_Account；若不填写默认情况下会将消息存From_Account漫游
        map.put("To_Account", uid);//消息接收方账号。
        map.put("MsgLifeTime", 604800);//消息离线保存时长（秒数），最长为7天（604800s）。若消息只发在线用户，不想保存离线，则该字段填0。若不填，则默认保存7天
        map.put("MsgRandom", TXCloudHelper.randomInt(Integer.MAX_VALUE));//消息随机数,由随机函数产生。（用作消息去重）
        map.put("MsgTimeStamp", System.currentTimeMillis() / 1000);//消息时间戳，unix时间戳。
        map.put("MsgBody", list);//设置消息体
        String json = JSON.toJSONString(map);
        JSONObject jObject = JSON.parseObject(TXCloudHelper.executePost(TXCloudHelper.getUrl(CloudData.openimSendmsg), json));
        return jObject.get("ActionStatus").toString().equals("OK") ? (byte) 1 : (byte) 0;
    }

    /**
     * 管理员发送推送
     *
     * @param msg
     * @return
     */
    public static byte ImPush(String msg) {
        Map<Object, Object> map = new HashMap<Object, Object>();//拼装json数据
        List<Object> list = new ArrayList<Object>();
        list.add(setMsgBody(msg));
        map.put("MsgRandom", TXCloudHelper.randomInt(Integer.MAX_VALUE));
        map.put("MsgBody", list);
        String json = JSON.toJSONString(map);
        JSONObject jObject = JSON.parseObject(TXCloudHelper.executePost(TXCloudHelper.getUrl(CloudData.openimIm_push), json));
        return jObject.get("ActionStatus").toString().equals("OK") ? (byte) 1 : (byte) 0;
    }

    /**
     * 设置用户属性
     *
     * @param userInfo
     * @return
     */
    public static boolean setPortrait(String uid, UserInfo userInfo) {
        List<Map<String, Object>> list = setProfileItem(userInfo);
        Map<Object, Object> map = new HashMap<Object, Object>();//拼装json数据
        map.put("From_Account", uid);
        map.put("ProfileItem", list);
        String json = JSON.toJSONString(map);
        JSONObject jObject = JSON.parseObject(TXCloudHelper.executePost(TXCloudHelper.getUrl(CloudData.setPortrait), json));
        return jObject.get("ActionStatus").toString().equals("OK") ? true : false;
    }

    /**
     * 获取用户属性
     *
     * @param uid
     * @return
     */
    public static String getPortrait(String uid) {
        List<String> list = new LinkedList<String>();
        list.add(nickname);
        list.add(image);
        list.add(sex);
        Map<Object, Object> map = new HashMap<Object, Object>();//拼装json数据
        map.put("TagList", list);
        List<String> accList = new LinkedList<String>();
        accList.add(uid);
        map.put("To_Account", accList);
        String json = JSON.toJSONString(map);
        JSONObject jObject = JSON.parseObject(TXCloudHelper.executePost(TXCloudHelper.getUrl(CloudData.getPortrait), json));
        if (!jObject.get("ActionStatus").toString().equals("OK")) {
            return null;
        } else {
            return JSON.toJSONString(getUserInfo(jObject));
        }
    }

    public static UserInfo getUserInfo(String uid) {
        List<String> list = new LinkedList<String>();
        list.add(nickname);
        list.add(image);
        list.add(sex);
        Map<Object, Object> map = new HashMap<Object, Object>();//拼装json数据
        map.put("TagList", list);
        List<String> accList = new LinkedList<String>();
        accList.add(uid);
        map.put("To_Account", accList);
        String json = JSON.toJSONString(map);
        JSONObject jObject = JSON.parseObject(TXCloudHelper.executePost(TXCloudHelper.getUrl(CloudData.getPortrait), json));
        if (!jObject.get("ActionStatus").toString().equals("OK")) {
            return new UserInfo();
        } else {
            return getUserInfo(jObject);
        }
    }

    /**
     * 增加好友,设置好友备注
     *
     * @param uid       用户uid
     * @param fuid      好友uid
     * @param addSource 加好友来源平台
     * @return
     */
    public static byte addFriend(String uid, String fuid, String Remark, String addSource) {
        Map<String, Object> map = new HashMap<String, Object>();
        LinkedList<Map<String, String>> list = new LinkedList<>();
        Map<String, String> fmap = new HashMap<String, String>();
        fmap.put("To_Account", fuid);//好友的Identifier。
        fmap.put("AddSource", "AddSource_Type_" + addSource);//加好友来源 如:AddSource_Type_Android
        if (!"".equals(Remark)) {
            fmap.put("Remark", Remark);
        }
        list.add(fmap);
        map.put("From_Account", uid);//需要为该Identifier添加好友。
        map.put("AddFriendItem", list);//好友结构体对象。

        String json = JSON.toJSONString(map);//拼装json数据
        JSONObject jObject = JSON.parseObject(TXCloudHelper.executePost(TXCloudHelper.getUrl(CloudData.addFriend), json));
        if (jObject.get("ActionStatus").toString().equals("OK")) {
            String relation = jObject.getJSONArray("ResultItem").getJSONObject(0).getString("ResultInfo");
            if (!relation.equals("SNS_FRD_ADD_FRD_EXIST"))//已经是好友
                return 1;
        }
        return 0;
    }

    /**
     * 删除好友
     *
     * @param uid  用户uid
     * @param fuid 好友uid
     * @return
     */
    public static byte deleteFriend(String uid, String fuid) {
        Map<String, Object> map = new HashMap<String, Object>();
        LinkedList<String> list = new LinkedList<>();
        list.add(fuid);
        map.put("From_Account", uid);//需要为该Identifier删除好友。
        map.put("To_Account", list);//待删除的好友的Identifier。
        map.put("DeleteType", "Delete_Type_Both");//双向删除好友
        String json = JSON.toJSONString(map);//拼装json数据
        JSONObject jObject = JSON.parseObject(TXCloudHelper.executePost(TXCloudHelper.getUrl(CloudData.deleteFriend), json));
        return jObject.get("ActionStatus").toString().equals("OK") ? (byte) 1 : (byte) 0;
    }

    /**
     * 检验好友
     *
     * @param uid  用户uid
     * @param fuid 好友uid
     * @return
     */
    public static byte checkFriend(String uid, String fuid) {
        Map<String, Object> map = new HashMap<String, Object>();
        LinkedList<String> list = new LinkedList<>();
        list.add(fuid);
        map.put("From_Account", uid);//需要为该Identifier校验好友。
        map.put("To_Account", list);//待校验的好友的Identifier。
        map.put("CheckType", "CheckResult_Type_Both");//双向校验好友关系
        String json = JSON.toJSONString(map);//拼装json数据
        JSONObject jObject = JSON.parseObject(TXCloudHelper.executePost(TXCloudHelper.getUrl(CloudData.checkFriend), json));
        if (jObject.get("ActionStatus").toString().equals("OK")) {
            String relation = jObject.getJSONArray("InfoItem").getJSONObject(0).getString("Relation");
            if (relation.equals("CheckResult_Type_BothWay"))
                return 1;
        }
        return 0;
    }

    /**
     * 获取指定单个好友信息
     *
     * @param uid
     * @param fuid
     * @return
     */
    public static String getOneFriend(String uid, String fuid) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("From_Account", uid);//需要拉取该Identifier的好友。

        LinkedList<String> To_Account = new LinkedList<String>();
        To_Account.add(fuid);
        map.put("To_Account", To_Account);//请求拉取的好友的Identifier列表

        LinkedList<String> flist = new LinkedList<String>();
        flist.add(nickname);//昵称
        flist.add(image);//头像URL
        flist.add(remark);//备注
        map.put("TagList", flist);//指定要拉取的资料字段及好友字段

        String json = JSON.toJSONString(map);//拼装json数据
        JSONObject jObject = JSON.parseObject(TXCloudHelper.executePost(TXCloudHelper.getUrl(CloudData.getFriend), json));

        String ResultInfo = jObject.getJSONArray("InfoItem").getJSONObject(0).getString("ResultInfo");

        if (ResultInfo.equals("SNS_FRD_GET_LIST_FRD_NO_EXIST"))//不是好友
        {
            return null;
        } else {
            FriendInfo friendInfo = new FriendInfo();
            friendInfo.setFuid(fuid);
            return JSON.toJSONString(getFriendInfo(friendInfo, jObject.getJSONArray("InfoItem").getJSONObject(0).getJSONArray("SnsProfileItem")));
        }
    }

    /**
     * 获取所有好友列表
     *
     * @param uid        用户uid
     * @param startIndex 拉取的起始位置
     * @return
     */
    public static String getAllFriend(String uid, int startIndex) {
        Map<String, Object> map = new HashMap<String, Object>();
        LinkedList<String> list = new LinkedList<>();
        list.add(nickname);//昵称
        list.add(image);//头像URL
        list.add(remark);//好友备注
        map.put("TagList", list);//指定要拉取的字段Tag
        map.put("From_Account", uid);//需要拉取该Identifier的好友。
        map.put("StartIndex", startIndex);//拉取的起始位置。
        map.put("GetCount", 50);//每页需要拉取的好友数量
        String json = JSON.toJSONString(map);//拼装json数据
        JSONObject jObject = JSON.parseObject(TXCloudHelper.executePost(TXCloudHelper.getUrl(CloudData.getAllFriend), json));

        List<FriendInfo> flist = new ArrayList<>();
        if (jObject.get("ActionStatus").toString().equals("OK")) {
            JSONArray jsona = jObject.getJSONArray("InfoItem");
            if (null != jsona && jsona.size() > 0) {
                for (Object object : jsona) {
                    JSONObject job = (JSONObject) object;
                    FriendInfo friendInfo = new FriendInfo();
                    friendInfo.setFuid(job.getString("Info_Account")); //好友uid
                    flist.add(getFriendInfo(friendInfo, job.getJSONArray("SnsProfileItem")));
                }
            }
        }

        return JSON.toJSONString(flist);
    }


    /**
     * 设置消息体内容
     *
     * @param msg
     * @return
     */
    public static Map<String, Object> setMsgBody(String msg) {
        Map<String, Object> msgMap = new HashMap<String, Object>();
        msgMap.put("MsgType", "TIMTextElem");
        HashMap<String, String> map = new HashMap<String, String>();
        map.put("Text", msg);
        msgMap.put("MsgContent", map);
        return msgMap;
    }

    /**
     * 设置资料对象数组(设置用户属性)
     *
     * @param userInfo
     * @return
     */
    public static List<Map<String, Object>> setProfileItem(UserInfo userInfo) {
        List<Map<String, Object>> list = new LinkedList<Map<String, Object>>();
        if (null != userInfo.getNickname() && !"".equals(userInfo.getNickname())) {
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("Tag", nickname);
            map.put("Value", userInfo.getNickname());
            list.add(map);
        }
        if (null != userInfo.getSex()) {
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("Tag", sex);
            if (0 == userInfo.getSex()) {
                map.put("Value", female);
            } else if (1 == userInfo.getSex()) {
                map.put("Value", male);
            } else {
                map.put("Value", "Gender_Type_Unknown");
            }
            list.add(map);
        }

        if (null != userInfo.getImage() && !"".equals(userInfo.getImage())) {
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("Tag", image);
            map.put("Value", userInfo.getImage());
            list.add(map);
        }
        return list;
    }

    /**
     * 获取用户信息
     *
     * @param json
     * @return
     */
    public static UserInfo getUserInfo(JSONObject json) {
        UserInfo userInfo = new UserInfo();
        JSONArray jsonArray = json.getJSONArray("UserProfileItem").getJSONObject(0).getJSONArray("ProfileItem");
        for (Object obj : jsonArray) {
            JSONObject ob = (JSONObject) obj;
            if (nickname.equals(ob.getString("Tag"))) {
                userInfo.setNickname(ob.getString("Value"));
            } else if (sex.equals(ob.getString("Tag"))) {
                if (ob.getString("Value").equals("Gender_Type_Unknown")) {
                    userInfo.setSex((byte) -1);//性别位置
                } else if (ob.getString("Value").equals(female)) {
                    userInfo.setSex((byte) 0);//女
                } else {
                    userInfo.setSex((byte) 1);//男
                }
            } else if (image.equals(ob.getString("Tag"))) {
                userInfo.setImage(ob.getString("Value"));
            }
        }
        return userInfo;

    }

    /**
     * 获取好友信息
     *
     * @param friendInfo
     * @param jsonar
     * @return
     */
    public static FriendInfo getFriendInfo(FriendInfo friendInfo, JSONArray jsonar) {
        if (jsonar.size() > 0) {
            for (Object object : jsonar) {
                JSONObject jobo = (JSONObject) object;
                if (jobo.getString("Tag").equals(nickname)) {
                    friendInfo.setNickname(jobo.getString("Value"));//昵称
                }
                if (jobo.getString("Tag").equals(image)) {
                    friendInfo.setImage(jobo.getString("Value")); //头像url
                }
                if (jobo.getString("Tag").equals(remark)) {
                    friendInfo.setRemark(jobo.getString("Value")); //备注
                }
            }
        }
        return friendInfo;
    }

    /**
     * 增加黑名单
     * */
    public static byte addBlack(String uid, String fuid) {
        Map<String, Object> map = new HashMap<String, Object>();
        LinkedList<String> list = new LinkedList<>();
        list.add(fuid);
        map.put("From_Account", uid);//需要为该Identifier删除好友。
        map.put("To_Account", list);//待删除的好友的Identifier。
        String json = JSON.toJSONString(map);//拼装json数据
        JSONObject jObject = JSON.parseObject(TXCloudHelper.executePost(TXCloudHelper.getUrl(CloudData.addBlackList), json));
        return jObject.get("ActionStatus").toString().equals("OK") ? (byte) 1 : (byte) 0;
    }

    /**
     * 移除黑名单
     * */
    public static byte deleteBlackList(String uid, String fuid) {
        Map<String, Object> map = new HashMap<String, Object>();
        LinkedList<String> list = new LinkedList<>();
        list.add(fuid);
        map.put("From_Account", uid);//需要为该Identifier删除好友。
        map.put("To_Account", list);//待删除的好友的Identifier。
        String json = JSON.toJSONString(map);//拼装json数据
        JSONObject jObject = JSON.parseObject(TXCloudHelper.executePost(TXCloudHelper.getUrl(CloudData.deleteBlackList), json));
        return jObject.get("ActionStatus").toString().equals("OK") ? (byte) 1 : (byte) 0;
    }

    /*校验黑名单*/
    public static byte checkBlack(String uid, String fuid) {
        Map<String, Object> map = new HashMap<String, Object>();
        LinkedList<String> list = new LinkedList<>();
        list.add(fuid);
        map.put("From_Account", uid);//需要为该Identifier删除好友。
        map.put("To_Account", list);//待删除的好友的Identifier。
        map.put("CheckType", "BlackCheckResult_Type_Singal");//单向校验
        String json = JSON.toJSONString(map);//拼装json数据
        JSONObject jObject = JSON.parseObject(TXCloudHelper.executePost(TXCloudHelper.getUrl(CloudData.checkBlackList), json));
        return jObject.getJSONArray("BlackListCheckItem").getJSONObject(0).get("Relation").toString().equals("BlackCheckResult_Type_NO") ? (byte) 0 : (byte) 1;
    }


    /*创建群组*/
    public static byte createGroup(String uid, String name, String GroupId) {
        //解散所有群组
        //sdestroyAllGroup(uid);
        Map<String, String> map = new HashMap<String, String>();
        map.put("Owner_Account", uid);
        //互动直播聊天室
        map.put("Type", "AVChatRoom");
        map.put("Name", name);
        map.put("GroupId", GroupId);
        String json = JSON.toJSONString(map);//拼装json数据
        JSONObject jObject = JSON.parseObject(TXCloudHelper.executePost(TXCloudHelper.getUrl(CloudData.createGroup), json));
        return jObject.get("ActionStatus").toString().equals("OK") ? (byte) 1 : (byte) 0;
    }

    /*解散群组*/
    public static byte destroyGroup(String GroupId) {
        Map<String, String> map = new HashMap<String, String>();
        map.put("GroupId", GroupId);
        String json = JSON.toJSONString(map);//拼装json数据
        JSONObject jObject = JSON.parseObject(TXCloudHelper.executePost(TXCloudHelper.getUrl(CloudData.destroyGroup), json));
        return jObject.get("ActionStatus").toString().equals("OK") ? (byte) 1 : (byte) 0;
    }


    /*增加群员-静默加人*/
    public static byte addGroupMember(String GroupId, String account) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("GroupId", GroupId);
        map.put("Silence", "1");
        LinkedList<Map> list = new LinkedList<>();
        Map<String, String> map2 = new HashMap<String, String>();
        map2.put("Member_Account", account);
        list.add(map2);
        map.put("MemberList", list);
        String json = JSON.toJSONString(map);//拼装json数据
        JSONObject jObject = JSON.parseObject(TXCloudHelper.executePost(TXCloudHelper.getUrl(CloudData.addGroupMember), json));
        return jObject.get("ActionStatus").toString().equals("OK") ? (byte) 1 : (byte) 0;
    }

    /*解散所有群组*/
    public static void destroyAllGroup(String account) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("Member_Account", account);
        map.put("GroupType", "ChatRoom");
        String json = JSON.toJSONString(map);//拼装json数据
        JSONObject jObject = JSON.parseObject(TXCloudHelper.executePost(TXCloudHelper.getUrl(CloudData.getJoinedGroupList), json));
        if (jObject.get("ActionStatus").toString().equals("OK")) {
            JSONArray jsonArray = jObject.getJSONArray("GroupIdList");
            for (int i = 0; i < jsonArray.size(); i++) {
                JSONObject object = jsonArray.getJSONObject(i);
                String id = (String) object.get("GroupId");
                destroyGroup(id);
            }
        }
    }

    /*是否是群成员*/
    public static boolean isGroupMember(String GroupId, String account) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("Member_Account", account);
        map.put("GroupType", "ChatRoom");
        String json = JSON.toJSONString(map);//拼装json数据
        JSONObject jObject = JSON.parseObject(TXCloudHelper.executePost(TXCloudHelper.getUrl(CloudData.getJoinedGroupList), json));
        Boolean flag = false;
        if (jObject.get("ActionStatus").toString().equals("OK")) {
            JSONArray jsonArray = jObject.getJSONArray("GroupIdList");
            for (int i = 0; i < jsonArray.size(); i++) {
                JSONObject object = jsonArray.getJSONObject(i);
                String id = (String) object.get("GroupId");
                if (GroupId.equals(id)) {
                    flag = true;
                } else {
                    //退群
                    deleteGroupMember(GroupId, account);
                }
            }
        }
        return flag;
    }

    /*删除群员-静默删除*/
    public static byte deleteGroupMember(String GroupId, String account) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("GroupId", GroupId);
        map.put("Silence", "1");
        LinkedList<String> list = new LinkedList<>();
        list.add(account);
        map.put("MemberToDel_Account", list);
        String json = JSON.toJSONString(map);//拼装json数据
        JSONObject jObject = JSON.parseObject(TXCloudHelper.executePost(TXCloudHelper.getUrl(CloudData.deleteGroupMember), json));
        return jObject.get("ActionStatus").toString().equals("OK") ? (byte) 1 : (byte) 0;
    }

    /*指定消息发送者-自定义消息*/
    public static byte sendGroupMsg(String GroupId, String account, Map param) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("GroupId", GroupId);
        map.put("From_Account", account);
        Integer random = TXCloudHelper.randomInt(Integer.MAX_VALUE);
        map.put("Random", random);
        LinkedList<Map> list = new LinkedList<>();
        Map map2 = setMsgBody(JSONObject.toJSONString(param));
        list.add(map2);
        map.put("MsgBody", list);
        String url = TXCloudHelper.getUrl(CloudData.sendGroupMsg);
        String json = JSON.toJSONString(map);//拼装json数据
        JSONObject jObject = JSON.parseObject(TXCloudHelper.executePost(url, json));
        return jObject.get("ActionStatus").toString().equals("OK") ? (byte) 1 : (byte) 0;
    }

    /*指定消息发送者-普通文本消息*/
    public static byte sendTextGroupMsg(String GroupId, String account, String text) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("GroupId", GroupId);
        map.put("From_Account", account);
        String random = RandomUtils.getRandomNumberString(32);
        map.put("Random", random);
        LinkedList<Map> list = new LinkedList<>();
        Map map2 = setMsgBody(text);
        list.add(map2);
        map.put("MsgBody", list);
        String json = JSON.toJSONString(map);//拼装json数据
        JSONObject jObject = JSON.parseObject(TXCloudHelper.executePost(TXCloudHelper.getUrl(CloudData.sendGroupMsg), json));
        return jObject.get("ActionStatus").toString().equals("OK") ? (byte) 1 : (byte) 0;
    }

    /**
     * 设置消息
     *
     * @param map
     * @return
     */
    public static Map<String, Object> MessageBody(Map map) {
        Map<String, Object> msgMap = new HashMap<String, Object>();
        msgMap.put("MsgType", "TIMCustomElem");
        msgMap.put("MsgContent", map);
        return msgMap;
    }

    /*设置禁言  shutUpTime禁言时间  0是解除禁言*/
    public static byte forbidSendMsg(String GroupId, String account, Integer shutUpTime) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("GroupId", GroupId);
        if (shutUpTime != null) {
            map.put("ShutUpTime", shutUpTime);
        }
        LinkedList<String> list = new LinkedList<>();
        list.add(account);
        map.put("Members_Account", list);
        String json = JSON.toJSONString(map);//拼装json数据
        JSONObject jObject = JSON.parseObject(TXCloudHelper.executePost(TXCloudHelper.getUrl(CloudData.forbidSendMsg), json));
        return jObject.get("ActionStatus").toString().equals("OK") ? (byte) 1 : (byte) 0;
    }

    /*获取漫游消息*/
    public static byte groupMsgGetSimple(String GroupId, Integer reqMsgNumber) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("GroupId", GroupId);
        map.put("ReqMsgNumber", reqMsgNumber);
        String json = JSON.toJSONString(map);//拼装json数据
        JSONObject jObject = JSON.parseObject(TXCloudHelper.executePost(TXCloudHelper.getUrl(CloudData.groupMsgGetSimple), json));
        return jObject.get("ActionStatus").toString().equals("OK") ? (byte) 1 : (byte) 0;
    }

    /*获取群组信息*/
    public static byte getGroupMemberInfo(String GroupId) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("GroupId", GroupId);
        String json = JSON.toJSONString(map);//拼装json数据
        JSONObject jObject = JSON.parseObject(TXCloudHelper.executePost(TXCloudHelper.getUrl(CloudData.getGroupMemberInfo), json));
        return jObject.get("ActionStatus").toString().equals("OK") ? (byte) 1 : (byte) 0;
    }

    /*获取群组人数*/
    public static Integer getGroupMemberNum(String GroupId) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("GroupId", GroupId);
        String json = JSON.toJSONString(map);//拼装json数据
        JSONObject jObject = JSON.parseObject(TXCloudHelper.executePost(TXCloudHelper.getUrl(CloudData.getGroupMemberInfo), json));
        if (jObject.get("ActionStatus").toString().equals("OK")) {
            String numString = jObject.getString("MemberNum");
            return Integer.valueOf(numString);
        }
        return 0;
    }

}
